package com.lgl.scsapi.util.utils;

import org.springframework.context.ApplicationContext;

import java.util.HashMap;
import java.util.Map;

/**
 * 常量类
 */

public class Constants {
	//微信小程序获取用户信息URL
	public static final String WX_MINI_GET_USER_INFO_URL = "https://api.weixin.qq.com/sns/jscode2session";
	/**
	 * 微信小程序app ID
	 */
	public static final String WX_MINI_APP_ID = "wxce33f721aca7f7b5";
	/**
	 * 微信小程序app secret
 	 */
	public static final String WX_MINI_APP_SECRET = "e0a16a8650cb081a7a8cd138542745f0";
	/**
	 * redis是否可用，true：可用，false:不可用
	 */
	public static boolean REDIS_IS_USABLE = true;
	/**
	 * 获取同城服务注册用户ID的流水号的redis key
	 */
	public static final String SCS_REG_U_ID_INCR = "s:u:i:incr";
	/**
	 * 获取全民吐槽注册用户ID的流水号的redis key
	 */
	public static final String VENT_REG_U_ID_INCR = "v:u:i:incr";
	/**
	 * 同城服务
	 * 由于目前用户注册的ID的后面的数字，是通过redis的REG_U_ID_INCR来实现累加的，
	 * 当redis不可用时，用户ID则是通过SQL获取用户表里ID最大值+1的方式获取，但此时，
	 * redis里的REG_U_ID_INCR值未变，等redis恢复后，还会在redis的基础上获取用户ID，
	 * 这样会导致重复的用户ID，所以需要使用U_ID_INCR_ADD来记录在redis不可用期间，
	 * 有多少个用户注册了，并重置REG_U_ID_INCR的值为：REG_U_ID_INCR的值+U_ID_INCR_ADD
	 */
	public static int SCS_U_ID_INCR_ADD = 0;
	public static int VENT_U_ID_INCR_ADD = 0;
	public static final String BILL_NO_DATE = "bn:";
	/**
	 * 手机验证码redis key前缀
	 */
	public static final String PHONE_CHECK_CODE_K_PRE = "pcc:";
	/**
	 * 某个手机验证码发送次数redis key前缀
	 */
	public static final String PHONE_SEND_TIMES = "pccS:T:";
	/**
	 * shiro加密盐值
	 */
	public final static String SHIRO_SALT = "$SCS&";
	/**
	 * shiro加密算法
	 */
	public static final String ALGORITHM_NAME = "SHA-256";
	/**
	 * shiro加密散列的次数
	 */
	public static final int HASH_ITERATIONS = 16;
	/**
	 * shiro cookie的有效时间为30天，单位秒
	 */
	public static final int SHIRO_REMEMBER_ME_SECONDS = 259200;

	public static final int PAGE_SIZE = 15;
	//不对匹配该值的访问路径拦截（正则）
	public static final String NO_INTERCEPTOR_PATH = ".*/((login)|(index)|(userPages)|(logout)|(code)|(app)|(staticFile)).*";
	/**
	 * 获取bean通过Constants.WEB_APP_CONTEXT.getBean(serviceName)
	 */
	public static ApplicationContext WEB_APP_CONTEXT = null; //该值会在web容器启动时由WebAppContextListener初始化
	/**
	 * 验证码获取最大次数
	 */
	public static final int CHECK_CODE_MAX_TIMES = 5;
	//public staticFile final String EHCACHE_ALL_CITIES_KEY = "all_cities_key";
	//public staticFile final String EHCACHE_ALL_AREA_KEY = "all_area_key";
	//public staticFile final String CACHE_CITY_KEY_PREFIX = "CACHE_CITY_KEY_PREFIX_";
	public static final String CACHE_AREA_KEY_PREFIX = "CACHE_AREA_KEY_PREFIX_";
	public static final String EHCACHE_STATIC_ANME = "staticDataCache";
	//public staticFile final String EHCACHE_SERVICE_TYPE_KEY = "SERVICE_TYPE_KEY";
	public static final Map<String, String> hotCityMap = new HashMap<String, String>(){{
		put("上海", "310100");
		put("北京", "110100");
		//put("杭州", "330100");
		//put("武汉", "420100");
		//put("天津", "120100");
		//put("长沙", "430100");
		put("广州", "440100");
		put("深圳", "440300");
		//put("成都", "510100");
	}};
	
	/**
	 * 热门城市ID数组,北京、上海、深圳、广州、杭州、天津
	 */
	public static final String[] HOT_CITY_IDS = {"110100","310100","440300","440100","330100","120100"};

	/**
	 * redis key前缀，字典类
	 */
	public static final String UI_PROVINCE = "UI_P_";
	/**
	 * redis key前缀，地址类
	 */
	public static final String UI_HOTCITY = "UI_H_C";
	/**
	 * redis key前缀，省类
	 */
	public static final String UI_AREA = "UI_A_";
	/**
	 * 数据字典redis key前缀
	 */
	public static final String DICT_PARENT_ID = "DICT_P_I_";
	/**
	 * redis key前缀，用户登录状态redis前缀
	 */
	public static final String USER_LOGIN_SET_PRE = "u:l:";

	/**
	 * 未登录状态码
	 */
	public static final int NO_LOGIN_CODE = -1;
	/**
	 * 没有权限码
	 */
	public static final int NO_AUTH_CODE = -2;
	/**
	 * 用户默认密码
	 */
	public static final String USER_DEFAULT_PASSWORD = "0";

	/*---------scs-header使用的常量-------------*/
	public static final String SESSION_SECURITY_CODE = "sessionSecCode";
	public static final String HEADER_NO_INTERCEPTOR_PATH = ".*/((login)|(staticFile)).*";
	//全部菜单
	public static final String SESSION_ALL_MENU = "allMenuList";
	public static final String SESSION_USER = "sessionUser";
	//public static final String SESSION_ROLE_RIGHTS = "sessionRoleRights";
	//public static final String SESSION_MENU_LIST = "menuList";
	public static final String SESSION_QX = "QX";
	/*public static final String SESSION_userpds = "userpds";
	public static final String SESSION_USERROL = "USERROL";				//用户对象
	public static final String SESSION_USERNAME = "USERNAME";*/			//用户名
	/**
	 * redis key前缀，字典类
	 */
	//public static final String UI_PROVICE = "UI_PROVICE";

	/*--------------全民吐槽项目使用--------------*/
	/**
	 * redis key前缀，用户登录状态redis前缀
	 */
	public static final String V_USER_LOGIN_SET_PRE = "v:u:l:";
}